#!/usr/bin/env python3

# -*- coding: utf-8 -*-

# @author: zhangbo

# @time: 2025/3/7 10:25\
import pytest
from typing import List

from utils.read_yaml import Read_yaml
from utils.tools import get_project_name, sep
from common.driver_config import DriverConfig
from page.LoginPage import LoginPage
from common.ObjectMap import ObjectMap


@pytest.fixture()
def test_pre():

    def _test_pre():
        """
        用例前置步骤
        :return:
        """
        yaml_path: List[str] = [sep([get_project_name(), r"config\login_config.yaml"])]

        # 读取用例所需参数
        config = Read_yaml(yaml_path).get_config_data("login_config")

        # 启动浏览器
        driver = DriverConfig().edge_Driver_Config()

        # 获取访问链接
        driver.get(config["login_config"]["url"])

        # 等待页面加载完成
        ObjectMap().wait_for_ready_state_complete(driver=driver)

        return driver, LoginPage(yaml_path)

    return _test_pre()
